package com.imoblife.brainwavestus.adapter;

import java.util.ArrayList;

import com.imoblife.brainwavestus.R;
import com.imoblife.brainwavestus.product.Product;
import com.imoblife.brainwavestus.util.BitMapFlyweightFactory;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AllProductCategoryAdapter extends BaseAdapter {
	
	public int mLayoutId;
	public Context mCtx;
	public LayoutInflater mInflater;
	public ArrayList<String> mCategoryData;
	
	public AllProductCategoryAdapter(Context ctx,int layoutId) {
		
		mCtx = ctx;
		mLayoutId = layoutId;
		mCategoryData = new ArrayList<String>();
		mInflater = (LayoutInflater) ctx
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	public AllProductCategoryAdapter(Context ctx,int layoutId, ArrayList<String> data) {
		
		mCtx = ctx;
		mLayoutId = layoutId;
		mCategoryData = data;
		mInflater = LayoutInflater.from(mCtx);
	}
	
	public AllProductCategoryAdapter setData(ArrayList<String> data) {
		
		mCategoryData = data;	
		return this;
	}
	
	@Override
	public int getCount() {
		
		return mCategoryData.size();
	}

	@Override
	public Object getItem(int position) {
		
		return null;
	}

	@Override
	public long getItemId(int position) {
	
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		TextView tvCategoryName = null;
		
		if (convertView == null) {

			convertView = mInflater.inflate(mLayoutId, null);
			
			tvCategoryName = 
					(TextView)convertView.findViewById(R.id.tv_category_name);	
			
			convertView.setTag(tvCategoryName);
		} else {
			
			tvCategoryName = (TextView) convertView.getTag();
		}
		
		tvCategoryName.setText(mCategoryData.get(position));
		
		return convertView;
	}
}
